package org.example.basic.lambda.stream;



import org.example.basic.entity.UserEntity;
import org.example.basic.entity.UserEntityList;

import java.util.List;

/**
 * takeWhile and dropWhile 案例
 * @author songyafei
 */
public class LambdaTakeWhile {

    public static void main(String[] args) {
        List<UserEntity> userEntityList = UserEntityList.getList();
        //forEach 不保证流中的顺序
        userEntityList.stream().takeWhile(a-> a.getAge()<18).forEach(System.out::println);
        System.out.println("---------------------------------------------------------------");
        //forEachOrdered 顺序流
        userEntityList.stream().dropWhile(a-> a.getAge()>60).forEachOrdered(System.out::println);
    }
}
